package me.zhengjie.modules.utils;

import com.deepoove.poi.XWPFTemplate;
import freemarker.template.Template;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.utils.FileUtil;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.io.*;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;

/**
 * @author CN-xianchengzhao
 * @description: TODO
 * @date 2021/12/8 22:00
 */
@Slf4j
@Component
public class CreateExportWordUtil {

    @Async
    public void export(Map<String, Object> root, String outFile) throws Exception {
        XWPFTemplate template = XWPFTemplate.compile("template.docx").render(
                root);
        template.writeAndClose(new FileOutputStream("output.docx"));
    }

}
